import request from '@/utils/request'
/**  获得活动关联商品列表(仅活动) */
export function getSkuActivity(params: any) {
    return request.get(`product/sku/get-general-sku-list-by-activity-id`, params, { isYuDao: true })
}
/**  获得单个商品，进行中的拼团、秒杀、砍价活动信息 */
export function getActivityListBySpuId(params: any) {
    return request.get(`promotion/activity/list-by-spu-id`, params, { isYuDao: true })
}
/**
 * 获取商品分类模板配置
 */
export function getGoodsCategoryConfig() {
    return request.get(`shop/goods/category/config`)
}

/**
 * 获取商品分类树结构
 */
export function getGoodsCategoryTree() {
    // return request.get(`shop/goods/category/tree`)
    return request.get(`product/category/list`, {}, { isYuDao: true })

}

/**
 * 获取商品分类列表
 */
export function getGoodsCategoryList(params: Record<string, any>) {
    return request.get(`shop/goods/category/list`, params)
}

/**
 * 获取商品列表
 */
export function getGoodsPages(params: Record<string, any>) {
    // return request.get(`shop/goods/pages`, params)
    if (uni.getStorageSync('wapShopMember')) {
        params.userId = uni.getStorageSync('wapShopMember').id;
    }
    return request.get(`product/spu/page`, params, { isYuDao: true })
}
/**
 * 获取商品结算(营销)信息
 */
export function getSettlementProduct(params: Record<string, any>) {
    return request.get(`trade/order/settlement-product`, params, { isYuDao: true })
}
/**
 * 获取商品详情
 */
export function getGoodsDetail(params: Record<string, any>) {
    // return request.get(`shop/goods/detail`, params)
    return request.get(`product/spu/get-detail`, params, { isYuDao: true })
}

/**
 * 获取商品规格
 */
export function getGoodsSku(sku_id: any) {
    return request.get(`shop/goods/sku/${sku_id}`)
}

/**
 * 收藏列表
 */
export function getCollectList(params: Record<string, any>) {
    return request.get(`shop/goods/collect`, params)
}

/**
 * 取消收藏
 */
export function cancelCollect(params: Record<string, any>) {
    return request.put(`shop/goods/collect`, params, { showSuccessMessage: true })
}

/**
 *  收藏
 */
export function collect(goods_id: any) {
    return request.post(`shop/goods/collect/${goods_id}`)
}


/**
 * 获取评价
 */
// export function getEvaluateList(goods_id: any) {
//     // return request.get(`shop/goods/evaluate/list`, { goods_id })
//     return request.get(`product/comment/page`, { spuId: goods_id, type: 0 }, { isYuDao: true })

// }
export function getEvaluateList(goods_id: any, pageNo: any,
    pageSize: any, type: any) {
    // return request.get(`shop/goods/evaluate/list`, { goods_id })
    return request.get(`product/comment/page`, {
        spuId: goods_id, pageNo,
        pageSize, type: type
    }, { isYuDao: true })

}

/**
 * 获取商品列表供组件调用
 */
// export function getGoodsComponents(params: Record<string, any>) {
//     return request.get(`shop/goods/components`, params)
// }
export function getGoodsComponents(params: Record<string, any>) {
    return request.get(`product/spu/list-by-ids`, params, { isYuDao: true })
}

/**
 * 获取商品满减信息
 */
export function getManjian(params: Record<string, any>) {
    return request.get(`shop/manjian/info`, params)
}

/**
 *  商品足迹添加
 */
export function browse(params: Record<string, any>) {
    return request.post(`shop/goods/browse`, params, { showSuccessMessage: false })
}
/**
 *  商品足迹列表
 */
export function getBrowse(params: Record<string, any>) {
    return request.get(`shop/goods/browse`, params)
}

/**
 * 商品足迹删除
 */
export function delBrowse(params: Record<string, any>) {
    return request.delete(`shop/goods/browse`, params)
}